//发布者，用来通知订阅者信息
;
(function(win) {
    function Dispatcher() {
        this.subs = [];
        this.uuid = uuid++;
    }

    Dispatcher.prototype = {
        addSub: function(sub) {
            this.subs.push(sub);
        },
        depend: function() {
            Dispatcher.target.addDispatcher(this);
        },
        removeSubs: function() {
            for (var i = this.subs.length - 1; i >= 0; i--) {
                this.subs.splice(i, 1);
            }
        },
        notify: function() {
            this.subs.forEach(function(sub) {
                sub.update();
            });
        }
    };

    Dispatcher.target = null;

    var uuid = 0;
    win.Dispatcher = Dispatcher;
})(window);